package newsrecommendation.datamodel.keywords;

import java.util.List;
import newsrecommendation.test.DataLoader;
import newsrecommendation.utils.StringUtils;

/**
 *
 * @author Andrea
 */
public class Keywords {

    private static List<String> allKeywords;
    private static Keywords instance;

    private Keywords() {
        allKeywords = DataLoader.get().getAllKeywords();
    }

    protected static Keywords get() {
        if (instance == null) {
            instance = new Keywords();
        }
        return instance;
    }
    protected int getSize() {
        return allKeywords.size();
    }

    protected int getKeywordPosition(String keywordSearch) {
    	if(keywordSearch.equals("")){
    		return -1;
    	}
    	
        int position = -1;
        keywordSearch = StringUtils.preprocess(keywordSearch);
        for (int i = 0; i < allKeywords.size(); i++) {
            if (allKeywords.get(i).contains(keywordSearch)) {
                position = i;
            }
        }
        return position;
    }

    //Borrar
    public String getKeyword(int position) {
        return allKeywords.get(position);
    }
    
    protected List<String> getAllKeywords() {
        return allKeywords;
    }
}
